home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / fido / mmail.000 / mmail / mmail.0.1 / interface / packet.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-27  |  2.8 KB  |  110 lines

  1. /*
  2.  * MultiMAIL offline mail reader
  3.  * 
  4.  
  5.    Written by Kolossvary Tamas (thomas@vma.bme.hu)
  6.  
  7.    This program is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License as published by
  9.    the Free Software Foundation; either version 2, or (at your option)
  10.    any later version.
  11.  
  12.    This program is distributed in the hope that it will be useful,
  13.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.    GNU General Public License for more details.
  16.  
  17.    You should have received a copy of the GNU General Public License
  18.    along with this program; if not, write to the Free Software
  19.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. #include <unistd.h>
  22. #include "interface.h"
  23.  
  24. extern mmail        mm;
  25. extern packet_list     *packetList;
  26. extern HelpWindow     helpwindow;
  27. extern AreaListWindow     areas;
  28.  
  29. PacketListWindow::PacketListWindow(void)
  30. {
  31.  packetList = mm.getPacketList(); 
  32. }
  33.  
  34. void PacketListWindow::MakeActive(void)
  35. {
  36.  init_pair(40, COLOR_YELLOW, COLOR_BLUE);
  37.  init_pair(42, COLOR_GREEN, COLOR_BLUE);
  38.  list = newwin(LINES-17, 60, 11, 10);
  39.  list_max_y = LINES-19;
  40.  wattrset(list, COLOR_PAIR(40) | A_BOLD);
  41.  for(int i=0; i < ((LINES-17)*60); i++)
  42.     waddch(list, ' ');
  43.  wborder(list, 0, 0, 0, 0, 0, 0, 0, 0);
  44.  wattrset(list, COLOR_PAIR(42) | A_BOLD);
  45.  mvwaddstr(list, 1, 1, "  Packet             Date"); 
  46.  wnoutrefresh(list);
  47.  
  48.  Draw();
  49.  helpwindow.packetlist();
  50. #ifdef SOUND_EFFECTS
  51.  system("zcat /var/lib/mmail/select.packet.au.gz >/dev/audio &");
  52. #endif
  53. }
  54.  
  55. int PacketListWindow :: NumOfItems(void)
  56. {
  57.  return packetList->getNoOfPackets();
  58. }
  59.  
  60. void PacketListWindow::Delete(void)
  61. {
  62.  delwin(list);
  63.  helpwindow.Delete();
  64.  touchwin(screen);
  65.  wnoutrefresh(screen);
  66. }
  67.  
  68. void PacketListWindow::Draw(void)
  69. {
  70.  int i, j;
  71.  char tmp1[13];
  72.  char tmp2[13];
  73.  
  74.  init_pair(41, COLOR_CYAN, COLOR_BLUE);
  75.  if(NumOfItems())
  76.  {
  77.   for(i=1; i<list_max_y; i++)
  78.   {
  79.     packetList->gotoPacket(position+i);
  80.  
  81.     strcpy(tmp1, "            ");
  82.     strcpy(tmp2, packetList->getName());
  83.     j=0;
  84.     while((tmp2[j] != '.') && (j < 8))
  85.         tmp1[j] = tmp2[j++];
  86.     strncpy(&tmp1[8], &tmp2[j], 4);
  87.  
  88.     wattrset(list, COLOR_PAIR(41) | A_BOLD);
  89.     if(position+i-1 == active) wattron(list, A_REVERSE);
  90.     mvwprintw(list, i+1,  1, "  %s", tmp1);
  91. //    mvwprintw(list, i+1, 15, "       %5d", packetList->getNoOfLetters());
  92. //    mvwprintw(list, i+1, 27, "       %5d", packetList->getNoOfPersonal());
  93. //    mvwprintw(list, i+1, 41, "       %5d      ", packetList->getNoOfUnread());
  94.     mvwprintw(list, i+1, 15, "       %s             ", packetList->getDate());
  95.     if((position+i) == NumOfItems()) i=list_max_y;
  96.   }
  97.   packetList->gotoPacket(active+1);
  98.  }
  99.  else 
  100.  {
  101.   wattrset(list, COLOR_PAIR(41) | A_BOLD);
  102.   mvwaddstr(list, 3, 12, "It seems we don't have packets.");
  103.   wrefresh(list);
  104.   sleep(2);
  105.   ungetch('Y');
  106.   ungetch('Q');
  107.  }
  108.  wnoutrefresh(list);
  109. }
  110.